<template>
  <div class="">
    <div class="action-wrapper">
      <div class="title" v-if="isShowTitle">{{ tips }}</div>
      <div class="message">{{ message }}</div>
      <div class="btn-box">
        <div class="btn-item" v-if="isShowCancalButton" @click="cancelClick">取消</div>
        <div class="btn-item" @click="clickEventFn">确定</div>
      </div>
    </div>
    <div class="mask"></div>
  </div>
</template>

<script>
export default {
  name: "ActionModal",
  props: {
    isShowTitle: {
      type: Boolean,
      default: true,
    },
    tips: {
      type: String,
      default: "提示",
    },
    message: {
      type: String,
      default: "是否确认删除？",
    },
    isShowCancalButton: {
      type: Boolean,
      default: true,
    },
  },
  methods: {
    clickEventFn() {
      this.$emit("clickEventFn",'confirm');
    },
    cancelClick(){
      this.$emit('clickEventFn','cancel')
    }
  },
};
</script>

<style scoped>
.mask {
  width: 100%;
  height: 100%;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.action-wrapper {
  width: 70%;
  border-radius: 10px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff;
  padding: 0 10px;
  z-index: 11;
  box-sizing: border-box;
}
.title {
  height: 40px;
  line-height: 40px;
  border-bottom: 2px solid #ccc;
  font-size: 18px;
  font-weight: bold;
}
.message {
  padding: 20px 10px;
  box-sizing: border-box;
}
.btn-box {
  display: flex;
  box-sizing: border-box;
  justify-content: space-between;
  text-align: center;
  /* border-top: 1px solid #ccc; */
}
.btn-box > div {
  padding: 10px;
  flex: 1;
  margin: 10px 5px 10px;
  color: #fff;
}
.btn-box > div:nth-child(1){
  background-color: #ccc;
}
.btn-box > div:nth-child(2) {
  border-left: 1px solid #ccc;
  background-color: var(--color-high-text);
  color:#fff;
  border-radius: 6px;
}
</style>